package ${packageName};

import ${basePackageName}entity.base.BoPage;
import org.springframework.web.bind.annotation.*;
import ${basePackageName}entity.${className};
import ${basePackageName}service.${className}Service;
import ${basePackageName}entity.bean.${className}Req;

import javax.annotation.Resource;

/**
 * @author： xw ftl auto
 * @create： ${.now?string("yyyy-MM-dd HH:mm:ss")}
 */
@RestController
@RequestMapping("/${className?uncap_first}")
public class ${className}Controller {

    @Resource
    private ${className}Service ${className?uncap_first}Service;

    /**
     * 简单的分页查询
     */
    @GetMapping("/page/{pageNumber}/{pageSize}")
    public BoPage<${className}> page${className}List(@PathVariable Integer pageNumber,@PathVariable Integer pageSize) {
        return ${className?uncap_first}Service.pageSample${className}(pageNumber,pageSize);
    }

    /**
     * 按条件分页查询
     */
    @PostMapping("/pageReq")
    public BoPage<${className}> pageReq(@RequestBody ${className}Req ${className?uncap_first}Req) {
        return ${className?uncap_first}Service.page${className}Mapper(${className?uncap_first}Req);
    }

    /**
     * 通过id查询详情
     */
    @GetMapping("/{id}")
    public ${className} get${className}ById(@PathVariable Long id) {
        return ${className?uncap_first}Service.getById(id);
    }

    /**
     * 新增
     */
    @PostMapping
    public boolean create${className}(@RequestBody ${className} ${className?uncap_first}) {
        return ${className?uncap_first}Service.save(${className?uncap_first});
    }

    /**
     * 通过id修改
     */
    @PostMapping("/put/{id}")
<#list fields as field>
    <#if field.name == "id">
    public boolean update${className}(@PathVariable ${field.type} id, @RequestBody ${className} ${className?uncap_first}) {
    <#else >
    </#if>
</#list>
        ${className?uncap_first}.setId(id);
        return ${className?uncap_first}Service.updateById(${className?uncap_first});
    }

    /**
     * 删除
     */
    @GetMapping("/delete/{id}")
    public void delete${className}(@PathVariable Long id) {
        ${className?uncap_first}Service.removeById(id);
    }

}
